﻿<UserControl x:Class="DTC.JournalChart"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Local="clr-namespace:DTC"
             xmlns:Converters="clr-namespace:DTC.Converters"
    MinHeight="300" MinWidth="300" SizeChanged="UserControl_SizeChanged">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources/ListBoxStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="{x:Type Local:VisitVisual}">
                <Setter Property="Background" Value="#FF4277DB"/>
                <Setter Property="BorderBrush" Value="#FF2943D3"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Local:VisitVisual}">
                            <Border Name="back" BorderBrush = "{TemplateBinding BorderBrush}" Background = "{TemplateBinding Background}" BorderThickness = "1" CornerRadius="1">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height = "0.55*"/>
                                        <RowDefinition Height = "0.45*"/>
                                    </Grid.RowDefinitions>
                                    <Grid Grid.RowSpan="2" Name="Glow" Opacity="0">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="0.5*"/>
                                            <ColumnDefinition Width="0.5*"/>
                                        </Grid.ColumnDefinitions>
                                        <Border Grid.Column = "0">
                                            <Border.Background>
                                                <RadialGradientBrush MappingMode="RelativeToBoundingBox" Center="-3.5,0.6" GradientOrigin="-4,0.5" RadiusX="4.6" RadiusY="1">
                                                    <GradientStop Color="#11FFFFFF" Offset="1"/>
                                                    <GradientStop Color="#AAFFFFFF" Offset="0.6"/>
                                                </RadialGradientBrush>
                                            </Border.Background>
                                        </Border>
                                        <Border Grid.Column = "1">
                                            <Border.Background>
                                                <RadialGradientBrush MappingMode="RelativeToBoundingBox" Center="4.5,0.6" GradientOrigin="5,0.5" RadiusX="4.6" RadiusY="1">
                                                    <GradientStop Color="#11FFFFFF" Offset="1"/>
                                                    <GradientStop Color="#AAFFFFFF" Offset="0.6"/>
                                                </RadialGradientBrush>
                                            </Border.Background>
                                        </Border>
                                    </Grid>
                                    <Border x:Name = "ShineTop" Grid.Row = "0" CornerRadius="1">
                                        <Border.Background>
                                            <LinearGradientBrush EndPoint="0.5,0.8" StartPoint="0.5,0">
                                                <GradientStop Color="#AAFFFFFF" Offset="0"/>
                                                <GradientStop Color="#33FFFFFF" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Border.Background>
                                    </Border>
                                    <Border x:Name = "ShineBottom" Grid.Row = "1" CornerRadius="1">
                                        <Border.Background>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0.3">
                                                <GradientStop Color="#00FFFFFF" Offset="0"/>
                                                <GradientStop Color="#22FFFFFF" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Border.Background>
                                    </Border>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="Glow" Property="Opacity" Value="1"/>
                                </Trigger>
                                <Trigger Property="IsPressed" Value="True">
                                    <Setter TargetName="back" Property="Background" Value="#FF003395"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="ToolTip">
                <Setter Property="DataContext" Value="{Binding Path=PlacementTarget,
                    RelativeSource={x:Static RelativeSource.Self}}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Background="White" BorderBrush="Gray" BorderThickness="1"
                                    CornerRadius="3" Height="Auto" Width="Auto">
                                <Grid Margin="10, 4, 10, 4">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.5*"/>
                                        <ColumnDefinition Width="13"/>
                                        <ColumnDefinition Width="0.5*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock FontSize="12" Foreground="Blue"
                                               Grid.Row="0" Grid.Column="0">
                                        <TextBlock.Text>
                                            <Binding Path="Visit.DateFrom" Mode="OneWay">
                                                <Binding.Converter>
                                                    <Converters:DateTimeToTimeConverter></Converters:DateTimeToTimeConverter>
                                                </Binding.Converter>
                                            </Binding>
                                        </TextBlock.Text>
                                    </TextBlock>
                                    <TextBlock FontSize="12" Foreground="Blue"
                                               Grid.Row="0" Grid.Column="1" Text=" - "
                                               HorizontalAlignment="Center"/>
                                    <TextBlock FontSize="12" Foreground="Blue"
                                               Grid.Row="0" Grid.Column="2">
                                        <TextBlock.Text>
                                            <Binding Path="Visit.DateTo" Mode="OneWay">
                                                <Binding.Converter>
                                                    <Converters:DateTimeToTimeConverter></Converters:DateTimeToTimeConverter>
                                                </Binding.Converter>
                                            </Binding>
                                        </TextBlock.Text>
                                    </TextBlock>
                                    <TextBlock FontSize="13" Foreground="Black"
                                               Grid.Row="1" Grid.ColumnSpan="3" 
                                               Margin="0,10,0,0"
                                               Text="{Binding Path=Visit.DTCPatient.Surname}"/>
                                    <TextBlock FontSize="13" Foreground="Black"
                                               Grid.Row="2" Grid.ColumnSpan="3" Text="{Binding Path=Visit.DTCPatient.Name}"/>
                                    <TextBlock FontSize="13" Foreground="Black"
                                               Grid.Row="3" Grid.ColumnSpan="3" Text="{Binding Path=Visit.DTCPatient.Fathername}"/>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border Background="White" BorderBrush="Gray" BorderThickness="1" SnapsToDevicePixels="True">
        <!--<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">-->
            <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="21"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.2*"/>
                <ColumnDefinition Width="0.8*"/>
            </Grid.ColumnDefinitions>
                <Border Grid.Column="0" Grid.Row="1"
                    HorizontalAlignment="Stretch" 
                    VerticalAlignment="Stretch"
                    BorderBrush="Gray" 
                    BorderThickness="0,1,1,0">
                <ScrollViewer Name="VerticalHeaderScroller" 
                              HorizontalScrollBarVisibility="Visible" 
                              HorizontalAlignment="Stretch"
                              VerticalScrollBarVisibility="Hidden">
                    <ListBox  Name="HeaderColumn" 
                              ItemContainerStyle="{StaticResource HeaderListItem}"
                              VerticalAlignment="Top"
                              Background="Blue"
                              SnapsToDevicePixels="True"
                              HorizontalContentAlignment="Stretch"
                              Style="{StaticResource HeaderColumnStyle}"
                              ScrollViewer.VerticalScrollBarVisibility="Auto"
                              BorderThickness="0">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Border Background="Transparent" BorderBrush="Gray" Height="21" BorderThickness="0,0,0,1">
                                    <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0"  Text="{Binding FullName}"/>
                                </Border>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </ScrollViewer>
            </Border>
            <Border BorderBrush="Gray" BorderThickness="1,0,0,1"
                    Grid.Column="1" Grid.Row="0" Margin="-1,0,0,-1">
            <ScrollViewer VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden"
                          SnapsToDevicePixels="True" Name="HorizontalHeaderScroller">
                <ListBox Name="HeaderRow"
                         ItemContainerStyle="{StaticResource HeaderRowItem}"
                         HorizontalContentAlignment="Stretch"
                         Style="{StaticResource HeaderRowStyle}"
                         ScrollViewer.VerticalScrollBarVisibility="Disabled"
                         ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                         BorderThickness="0" SnapsToDevicePixels="True"
                         Height="21" Margin="1,0,17,0"
                         >

                </ListBox>
                </ScrollViewer>
            </Border>
            <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Grid.Column="1" Grid.Row="1" ScrollChanged="ScrollViewer_ScrollChanged"  >
                    <Local:Chart x:Name="BChart" Width="400" 
                                 HorizontalAlignment="Center" 
                                 VerticalAlignment="Top" MinHeight="280" 
                                 SnapsToDevicePixels="True"
                                 MouseMove="BChart_MouseMove"
                                 MouseLeftButtonUp="BChart_MouseLeftButtonUp"
                                 MouseLeftButtonDown="BChart_MouseLeftButtonDown"/>
                </ScrollViewer>
            </Grid>
        <!--</ScrollViewer>-->
    </Border>
</UserControl>
